//导入request.js请求工具
import request from "@/utils/request.js";

//提供调用注册接口的函数
export const userRegisterService = (registerData) =>{
    //借助URLSearchParams完成传递
    const params = new URLSearchParams()
    for (let key in registerData){
        params.append(key,registerData[key]);
    }
    return request.post('/user/register',params);
}
//登录接口的函数
export const userLoginService = (loginData) =>{
    //借助URLSearchParams完成传递
    const params = new URLSearchParams()
    for (let key in loginData){
        params.append(key,loginData[key]);
    }
    return request.post('/user/login',params);
}

export const getLanList = () => {
    return request.get('/user/listLan')
}
export const getIntList = () => {
    return request.get('/user/listInt')
}
export const getCusList = () => {
    return request.get('/user/listCus')
}
//获取个人信息
export const userInfoGetService = ()=>{
    return request.get('/user/userInfo');
}


//所有用户
export const listAllArray=(UserData)=>{
    return request.post('/user/listAll',UserData)
}
//增加用户addUser
export const addUserDataInfo=(addUserData)=>{
    return request.post('/user/addUser',addUserData)
}

//修改用户
export const updateUserInfo=(updateUserData)=>{
    return request.post('/user/updateUser',updateUserData)
}
export const userAvatarUpdate = (avatarurl) =>{
    const  params = new URLSearchParams();
    params.append('avatarUrl',avatarurl)
    return request.patch('/user/updateAvatar',params)
}
export const updatePwd = (params, token) => {
    return request.patch('/user/updatePwd', params, {
        headers: {
            'Authorization': token
        }
    });
}

